fix(cli): fail closed when messages get targets a nonexistent channel - #6449
Open
sanjay3290 wants to merge 1 commit into
Open
fix(cli): fail closed when messages get targets a nonexistent channel#6449sanjay3290 wants to merge 1 commit into
sanjay3290 wants to merge 1 commit into
Conversation
Signed-off-by: Sanjay Ramadugu <sramadugu1@gmail.com> Co-authored-by: Sanjay Ramadugu <sramadugu1@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6389.
Problem
buzz messages get --channel <uuid>prints[]and exits 0 when the channel does not exist or the caller is not a member. That is indistinguishable from a channel with no messages, so scripts cannot tell "no messages yet" from "wrong UUID".Change
cmd_get_messagesprobes for the channel'skind:39000discovery event by#dbefore querying messages. If the probe returns no event, it returnsCliError::NotFound, which exits 1.This also covers the unauthorized case from the issue:
kind:39000events are stored channel-scoped, so a non-member's probe comes back empty and the command fails closed rather than reporting an empty history.The probe filter matches the one
cmd_get_channelalready uses incrates/buzz-cli/src/commands/channels.rs.Before / after
Tests
Two unit tests in
crates/buzz-cli/src/commands/messages.rs, each against a local stub relay:cmd_get_messages_fails_when_channel_not_found— probe returns[], expectCliError::NotFoundcmd_get_messages_succeeds_when_channel_exists— probe returns akind:39000event, expectOkand the messages printedThe first test fails on
mainwithexpected NotFound, got Ok(()).Verification
Run on this branch, rebased on
24ec6a4:Notes
messages get. That seemed the right trade for a correct exit code, but I am happy to gate it behind a flag if you would rather not pay it on the hot path.messages getonly.messages thread,channels members, andcanvas gethave the same silent-empty behaviour and are left alone here.